package com.fenghongzhang.day009.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;

import com.fenghongzhang.day009.R;
import com.fenghongzhang.day009.util.SpUtils;

/**
 * A simple {@link Fragment} subclass.
 */
public class LoginFragment extends Fragment {
    private EditText fgLoginName;
    private EditText fgLoginPwd;
    private Button login;
    private Button register;
    public LoginFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        View inflate = inflater.inflate(R.layout.fragment_login, container, false);
        fgLoginName = (EditText) inflate.findViewById(R.id.fg_login_name);
        fgLoginPwd = (EditText) inflate.findViewById(R.id.fg_login_pwd);
        login = (Button) inflate.findViewById(R.id.login);
        register = (Button) inflate.findViewById(R.id.register);


        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //登录以后要做的事.
                //存sp -> id
//                SpUtils.get.put
                //数据库-> 用户的详细信息


            }
        });

        register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mylistener.click(1);
            }
        });
        return inflate;
    }

    public interface Mylistener{
        void click(int i);
    }

    private Mylistener mylistener;

    public Mylistener getMylistener() {
        return mylistener;
    }

    public void setMylistener(Mylistener mylistener) {
        this.mylistener = mylistener;
    }
}
